package com.zl.autocode.common.utils.generator.model;

import java.util.ArrayList;
import java.util.List;

import lombok.Getter;
import lombok.Setter;

/**
 * 表属性
 * 
 * @author ZL
 */
@Getter
@Setter
public class ConvertTable {
    
    /***************基础属性***************/
    /** 表编码.  */
    private String tableCode;
    
    /** 原始编码.  */
    private String tableName;
    
    /** 表COMMENT.  */
    private String tableComment;
    
    /** 标签.  */
    private String tableTag;
    
    /** 驼峰CODE.  */
    private String tableJavaCode;
    
    /** 驼峰CODE(全).  */
    private String tableJavaFullCode;
    
    /** 表别名.  */
    private String tableAlias;
    
    /** 表字段*/
    private List<ConvertColumn> allcols;
    
    /** 表标题.  */
    private String tableTitle;
    
    private String currentSchema;
    
    /***************扩展属性***************/
    
    
    
    public List<ConvertColumn> getPkColumn() {
        if (this.allcols == null) {
            return null;
        }
        List<ConvertColumn> list = new ArrayList<>();
        for (ConvertColumn c : this.getAllcols()) {
            if ("1".equals(c.getColumnPrimarykey())) {
                list.add(c);
            }
        }
        if (list.isEmpty()) {
            return null;
        }
        return list;
    }
    public List<ConvertColumn> getGeneralColumn() {
        if (this.allcols == null) {
            return null;
        }
        List<ConvertColumn> list = new ArrayList<>();
        for (ConvertColumn c : this.getAllcols()) {
            if (!"1".equals(c.getColumnPrimarykey())) {
                list.add(c);
            }
        }
        if (list.isEmpty()) {
            return null;
        }
        return list;
    }
}
